<template>
  <div id="#app">
    <keep-alive include="index">
      <router-view></router-view>
    </keep-alive>
    <scroll-top></scroll-top>
  </div>
</template>

<script>
import ScrollTop from "./common/ScrollTop";

export default {
  name: "App",
  components: {
    ScrollTop
  },
  mounted() {
    //写在mounted或者activated生命周期内即可
    window.onbeforeunload = e => {
      let carList = this.$store.state.carList;
      console.log(carList);
      localStorage.setItem("carList", JSON.stringify(carList));
    };
  },
  beforeDestroy() {
    let carList = this.$store.state.carList;
    console.log(carList);
    localStorage.setItem("carList", JSON.stringify(carList));
  }
};
</script>

<style scoped lang="scss">
</style>
